package com.hongxin.nw.netty.utils.pools;

import com.hongxin.nw.netty.model.analysis.ASDUstart;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 设备编码对应登录信息 列表操作
 */
public class AsduStartPools {
    //设备编号 对应 启动协议帧
    private final static Map<String, ASDUstart> ASDUList = new ConcurrentHashMap<>();
    public static int getSize(){
        return ASDUList.size();
    }
    public static ASDUstart getAsduStart(final String code) throws Exception {
        if (ASDUList.containsKey(code)) {
            return ASDUList.get(code);
        }else{
            throw new Exception("启动协议帧数据找不到,设备: " + code);
        }
    }
    public static void addAsduStart(final String code, final ASDUstart o) {
        ASDUList.put(code, o);
    }
    public static void removeAsduStart(final String code) {
        if (ASDUList.containsKey(code)){
            ASDUList.remove(code);
        }
    }
}